home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / lu62 / alloc_rc.c < prev    next >
C/C++ Source or Header  |  1996-07-10  |  5KB  |  171 lines

  1. /**************************************************************/
  2. /*                                                            */
  3. /*                ALLOCATE_RCB_PROC                           */
  4. /*                    alloc_rcb                               */
  5. /*                                                            */
  6. /*   FUNCTION : This procedure has deal with allocation and   */
  7. /*   initialisation of the  Resource Control Blocks (RCBs)    */
  8. /*                                                            */
  9. /*   INPUT : Allocate_RCB record.                             */
  10. /*   OUTPUT: Rcb_allocated record.                            */
  11. /**************************************************************/
  12. /*
  13.  * CopyRight 1995. Nicholas Poljakov all rights reserved.
  14.  *
  15.  */
  16. #include <stdio.h>
  17. #include <arcb.h>
  18. #include <rcb.h>
  19. #include <tcb.h>
  20. #include <psp.h>
  21. #include <lucb.h>
  22. #include <rcballoc.h>
  23. #include <state1.h>
  24. #include <malloc.h>
  25. #include <string.h>
  26.  
  27. struct psp psp_ini;
  28. int sk_r_wt(void *);
  29. int SendBlock(void *, void *);
  30. int setrc(void *, void *);
  31. int sendhsf(void *);
  32. int sendhs(void *);
  33. int sendbm(void *, void *);
  34. int sendat(void *);
  35. int rtsend(void *);
  36. unsigned long rmfmh5(void *, void *);
  37. int recwait(void *);
  38. int rcvru(void *, void *);
  39. int rcvhs(void *, void *, void *, void *);
  40. int ralloc(void *, void *);
  41. int psrm(int, void *, void *);
  42. int ps_conv(int, void *);
  43. int proterr(void *, unsigned long);
  44. int preptrcv(void *, void *);
  45. int post_rcb(void *);
  46. struct repass *postopen(void *);
  47. int phsrec(void *);
  48. int pfmh5(void *);
  49. int opndst(void *);
  50. int obtsess(void *, unsigned char);
  51. int Lrf_handler(void *);
  52. int get_sess(void *, void *);
  53. int get_attr(void *);
  54. int fsm_error(unsigned char, void *);
  55. int fsm_conv(unsigned char, unsigned char, void *);
  56. int flush (void *);
  57. int dcp(void *);
  58. int dealloc(void *);
  59. int crtp(void *);
  60. int conv(void *);
  61. int chkparm(void *, void *);
  62. int check_end(unsigned int, void *);
  63. struct rqb *call_appl(void *);
  64. int buffmng(unsigned char, void *, void *, void *, unsigned, unsigned char, unsigned);
  65. unsigned long attltck(void *);
  66. unsigned long attacheck(void *);
  67. char *cgetmem(int, int);
  68. int sendhsf(void *);
  69. int opndst(void *);
  70. int allocate(void *);
  71. int clsdst(void *);
  72.  
  73. alloc_rcb(in, out)
  74. char *in;
  75. char *out;
  76. {
  77.     struct arcb *p_arcb;
  78.     struct rcballoc *p_rcba;
  79.     struct rcb *p_rcb;
  80.     struct rcb *temp;
  81.     struct tcb *p_tcb;
  82.     char *p;
  83.     unsigned long ui;
  84.  
  85. #if OS_TYPE == 1
  86. /*********  Trace facility **********/
  87. unsigned int rtype;   /* type of record */
  88. unsigned int pnum;    /* point number */
  89. char pname[8];        /* name of module */
  90. char *drec;       /* record for dump */
  91. int  lenr;            /* record length */
  92.  
  93. rtype = INPROC;
  94. strcpy(pname, "alloc_r");
  95. pnum = 1;
  96. drec = NULL;
  97. lenr = 0;
  98. gtf(rtype, pname, pnum, drec, lenr);
  99. /***********************************/
  100. #endif
  101.  
  102.  
  103.     p_arcb = (struct arcb *)in;
  104.     p_rcba = (struct rcballoc *)out;
  105.     p_rcba -> rc = OK;
  106.     p_tcb = p_arcb -> p_tcb;
  107.  
  108.     if ((p_rcb = calloc(1, sizeof(struct rcb))) == NULL) {
  109.         p_rcba -> rc = UNSUCCESSFUL;
  110.     return 0;
  111.     }
  112.     p_rcb -> p_tcb = p_tcb;
  113.     memcpy(p_rcb -> lu_name, p_arcb -> lu_name, 8);
  114.     memcpy(p_rcb -> mode_name, p_arcb -> mode_name, 8);
  115.     p_rcb -> p_lucb = psp_ini.lucb_list_ptr;
  116.     p_rcb -> conv_type = BASED;
  117.     p_rcb -> code = ASCII;
  118.     p_rcb -> session_parm_ptr = NULL;
  119.     p_rcb -> ps_to_hs_record = NULL;
  120.     p_rcb -> send_ll_remainder = 0;
  121.     p_rcb -> receive_remainder = 0;
  122.     p_rcb -> send_ll_byte = 0;
  123.     p_rcb -> saved_byte = 0;
  124.     p_rcb -> sync_level = NONE;
  125.     p_rcb -> rq_to_send_rcvd = No;
  126.     p_rcb -> hsps = No;
  127.     p_rcb -> cdind = 0;
  128.     p_rcb -> rbptr = NULL;
  129.     p_rcb -> verb_ptr = NULL;
  130.     p_rcb -> next = NULL;
  131.     p_rcb -> prev = NULL;
  132.     p_rcb -> Dir_next = NULL;
  133.     p_rcb -> In_count = 0;
  134.     p_rcb -> Out_count= 0;
  135.     p_rcb -> first_in = NULL;
  136.     p_rcb -> first_out = NULL;
  137.     p_rcb -> p_scb = NULL;
  138.     p_rcb -> error_state = NO_RQS;
  139.     p_rcb -> conv_state = RESET;
  140. /*
  141.  * Set RCB_ID
  142.  */
  143.     p_tcb -> cur_conv++;
  144.  
  145.     p = (char *)&((*p_rcb).rcb_id);
  146.     p[0] = 'C';
  147.     p[1] = '.';
  148.     ui = p_rcb;
  149.     p += 2;
  150.     memcpy(p, &ui, 2);
  151.  
  152.  /*
  153.   * Place RCB in rcb list.
  154.   */
  155.     temp = p_tcb -> rcb_list_ptr;
  156.     if (temp == NULL) {
  157.         p_tcb -> rcb_list_ptr = p_rcb;
  158.     }
  159.     else
  160.             {
  161.                 while (temp -> next != NULL) {
  162.                     temp = temp -> next;
  163.                 }
  164.                 temp -> next = p_rcb;
  165.                 p_rcb -> prev = temp;
  166.             }
  167.  
  168.     p_rcba -> rcb_ptr = p_rcb;
  169.     return 0;
  170. }
  171.